#!/usr/bin/env python
'''
module to setup veggie database

http://elixir.ematia.de/trac/wiki/Recipes/SplittingAModelAcrossMultipleFiles

Created on May 17, 2009

@author: mkiyer
'''
from elixir import setup_all, create_all, metadata

def init_db(dburl, echo=True):
    '''
    initialize elixir/sqlalchemy database entities
    '''
    # bind to a database
    metadata.bind = dburl
    metadata.bind.echo = echo
    # import the database entities
    from veggie.db import *
    # tell elixir to setup the database relationships
    setup_all()
    create_all()

# TODO: write function to cleanup/drop/destroy databases